<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1> 循环计算  个人所得税 </h1>
 <script>
    //最大值
    let max = Number.MAX_SAFE_INTEGER; 
    let cn = [ 
        {b:5000, e:8000 , rax:0.03},
        {b:8000, e:17000 , rax:0.1},
        {b:17000, e:30000 , rax:0.2},
        {b:30000, e:40000 , rax:0.25},
        {b:40000, e:60000 , rax:0.3},
        {b:60000, e:85000 , rax:0.35},
        {b:85000, e: max ,rax:0.45}
    ];

    let money = 90000;  //月薪
    let r = 0 ;     //交多少税

    if(money > 5000){
        for(let i =0;i< cn.length; i++){
            let c =  cn[i];
            console.log( c );
            if( money >= c.e ){
                r += (c.e-c.b)* c.rax ;
            }else{
                r += (money - c.b)* c.rax ;
                break;
            }
        }
        console.log( "交税= " + r);
    }else{
        console.log( "不用交税");
    }
    

 </script>   
</body>
</html>